#include "Train.h"

class Solution {
public:
    int maxArea(vector<int>& height) {
        int left = 0, right = height.size() - 1, ans = 0;
        while (left < right)
        {
            ans = max(ans, min(height[left], height[right]) * (right - left));
            if (height[left] < height[right])
            {
                //ans = max(ans, height[left] * (right - left));
                left++;
            }
            else {
               // ans = max(ans, height[right] * (right - left));
                right--;
            }
        }
        return ans;
    }
};